﻿namespace Services
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using DAL;
    using Entities;

    public class FilterService : IFilterService
    {
        #region Member Variables
        protected readonly IGenericRepository<FAEntities, AuditedOperation> repository;
        #endregion

        #region Constructor
        public FilterService(IGenericRepository<FAEntities, AuditedOperation> repository)
        {
            this.repository = repository;
        }
        #endregion

        #region IFilterService
        IEnumerable<string> IFilterService.GetUsers()
        {
            var users = from o in repository.Context.AuditedOperations
                        where !string.IsNullOrEmpty(o.UserAccount)
                        select o.UserAccount;
            return users.Distinct();
        }

        IEnumerable<string> IFilterService.GetFileTypes()
        {
            var fileTypes = from o in repository.Context.AuditedOperations
                            where !string.IsNullOrEmpty(o.FileType)
                            select o.FileType;
            return fileTypes.Distinct();
        }

        IEnumerable<string> IFilterService.GetHosts()
        {
            var hosts = from o in repository.Context.AuditedOperations
                        where !string.IsNullOrEmpty(o.ServerName)
                        select o.ServerName;
            return hosts.Distinct();
        }

        #endregion
    }
}